package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ZhwyChargeitem;
import com.ruoyi.service.IZhwyChargeitemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收费项管理Controller
 * 
 * @author zq
 * @date 2024-05-07
 */
@RestController
@RequestMapping("/charge/chargeitem")
public class ZhwyChargeitemController extends BaseController
{
    @Autowired
    private IZhwyChargeitemService zhwyChargeitemService;

    /**
     * 查询收费项管理列表
     */
    @PreAuthorize("@ss.hasPermi('charge:chargeitem:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZhwyChargeitem zhwyChargeitem)
    {
        startPage();
        List<ZhwyChargeitem> list = zhwyChargeitemService.selectZhwyChargeitemList(zhwyChargeitem);
        return getDataTable(list);
    }

    /**
     * 导出收费项管理列表
     */
    @PreAuthorize("@ss.hasPermi('charge:chargeitem:export')")
    @Log(title = "收费项管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZhwyChargeitem zhwyChargeitem)
    {
        List<ZhwyChargeitem> list = zhwyChargeitemService.selectZhwyChargeitemList(zhwyChargeitem);
        ExcelUtil<ZhwyChargeitem> util = new ExcelUtil<ZhwyChargeitem>(ZhwyChargeitem.class);
        util.exportExcel(response, list, "收费项管理数据");
    }

    /**
     * 获取收费项管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('charge:chargeitem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zhwyChargeitemService.selectZhwyChargeitemById(id));
    }

    /**
     * 新增收费项管理
     */
    @PreAuthorize("@ss.hasPermi('charge:chargeitem:add')")
    @Log(title = "收费项管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZhwyChargeitem zhwyChargeitem)
    {
        return toAjax(zhwyChargeitemService.insertZhwyChargeitem(zhwyChargeitem));
    }

    /**
     * 修改收费项管理
     */
    @PreAuthorize("@ss.hasPermi('charge:chargeitem:edit')")
    @Log(title = "收费项管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZhwyChargeitem zhwyChargeitem)
    {
        return toAjax(zhwyChargeitemService.updateZhwyChargeitem(zhwyChargeitem));
    }

    /**
     * 删除收费项管理
     */
    @PreAuthorize("@ss.hasPermi('charge:chargeitem:remove')")
    @Log(title = "收费项管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zhwyChargeitemService.deleteZhwyChargeitemByIds(ids));
    }
}
